     
**************************************************
**************************************************
******* TABLE 3 & Table 4 ************************
**************************************************
**************************************************


set more off
use  "${data}Panel_quarterly.dta", replace

label variable quarter_to_exhaustion_plus1 "$ T-1$"
label variable quarter_to_exhaustion_plus2 "$ T-2$"
label variable quarter_to_exhaustion_plus3 "$ T-3$"
label variable quarter_to_exhaustion_plus4 "$ T-4$"
label variable quarter_to_exhaustion_0 "$ T$"
label variable quarter_to_exhaustion_minus1 "$ T+1$"
label variable quarter_to_exhaustion_minus2 "$ T+2$"
label variable quarter_to_exhaustion_minus3 "$ T+3$"
label variable quarter_to_exhaustion_minus4 "$ T+4$"

******* Sample:

keep if analysis_sample==1


**************************************************
******* TABLE 3 **********************************
**************************************************


set more off

global var "Count_Application"

xi :  poisson ${var} ${MainQTE} ${OtherQTE}    i.PBD  				,    vce(robust)
 nlcom     (Average: exp((_b[quarter_to_exhaustion_0]+_b[quarter_to_exhaustion_minus1]+_b[quarter_to_exhaustion_minus2]+_b[quarter_to_exhaustion_minus3]+_b[quarter_to_exhaustion_minus4])/5)-1)  (quarter_to_exhaustion_plus3:exp(_b[quarter_to_exhaustion_plus3])-1) (quarter_to_exhaustion_plus2:exp(_b[quarter_to_exhaustion_plus2])-1) (quarter_to_exhaustion_plus1:exp(_b[quarter_to_exhaustion_plus1])-1) (quarter_to_exhaustion_0:exp(_b[quarter_to_exhaustion_0])-1 )   (quarter_to_exhaustion_minus1:exp(_b[quarter_to_exhaustion_minus1])-1) (quarter_to_exhaustion_minus2:exp(_b[quarter_to_exhaustion_minus2])-1) (quarter_to_exhaustion_minus3:exp(_b[quarter_to_exhaustion_minus3])-1) (quarter_to_exhaustion_minus4:exp(_b[quarter_to_exhaustion_minus4])-1 ) , post
		estadd local SpellFE "No"
		estadd local SpellTimeFE "No"
		estadd local PBDFE "Yes"
est store m1

xi :  poisson ${var} ${MainQTE} ${OtherQTE} ${SpellTimeFE}  i.PBD  	,    vce(robust)
 nlcom     (Average: exp((_b[quarter_to_exhaustion_0]+_b[quarter_to_exhaustion_minus1]+_b[quarter_to_exhaustion_minus2]+_b[quarter_to_exhaustion_minus3]+_b[quarter_to_exhaustion_minus4])/5)-1)  (quarter_to_exhaustion_plus3:exp(_b[quarter_to_exhaustion_plus3])-1) (quarter_to_exhaustion_plus2:exp(_b[quarter_to_exhaustion_plus2])-1) (quarter_to_exhaustion_plus1:exp(_b[quarter_to_exhaustion_plus1])-1) (quarter_to_exhaustion_0:exp(_b[quarter_to_exhaustion_0])-1 )   (quarter_to_exhaustion_minus1:exp(_b[quarter_to_exhaustion_minus1])-1) (quarter_to_exhaustion_minus2:exp(_b[quarter_to_exhaustion_minus2])-1) (quarter_to_exhaustion_minus3:exp(_b[quarter_to_exhaustion_minus3])-1) (quarter_to_exhaustion_minus4:exp(_b[quarter_to_exhaustion_minus4])-1 ) , post
		estadd local SpellFE "No"
		estadd local SpellTimeFE "Yes"
		estadd local PBDFE "Yes"
est store m2

xi : xtpoisson ${var} ${MainQTE} ${OtherQTE}     										,   fe vce(robust)
 nlcom     (Average: exp((_b[quarter_to_exhaustion_0]+_b[quarter_to_exhaustion_minus1]+_b[quarter_to_exhaustion_minus2]+_b[quarter_to_exhaustion_minus3]+_b[quarter_to_exhaustion_minus4])/5)-1)  (quarter_to_exhaustion_plus3:exp(_b[quarter_to_exhaustion_plus3])-1) (quarter_to_exhaustion_plus2:exp(_b[quarter_to_exhaustion_plus2])-1) (quarter_to_exhaustion_plus1:exp(_b[quarter_to_exhaustion_plus1])-1) (quarter_to_exhaustion_0:exp(_b[quarter_to_exhaustion_0])-1 )   (quarter_to_exhaustion_minus1:exp(_b[quarter_to_exhaustion_minus1])-1) (quarter_to_exhaustion_minus2:exp(_b[quarter_to_exhaustion_minus2])-1) (quarter_to_exhaustion_minus3:exp(_b[quarter_to_exhaustion_minus3])-1) (quarter_to_exhaustion_minus4:exp(_b[quarter_to_exhaustion_minus4])-1 ) , post
		estadd local SpellFE "Yes"
		estadd local SpellTimeFE "No"
		estadd local PBDFE "No"
est store m3

xi : xtpoisson ${var} ${MainQTE} ${OtherQTE} ${SpellTimeFE}    								,   fe vce(robust)
 nlcom     (Average: exp((_b[quarter_to_exhaustion_0]+_b[quarter_to_exhaustion_minus1]+_b[quarter_to_exhaustion_minus2]+_b[quarter_to_exhaustion_minus3]+_b[quarter_to_exhaustion_minus4])/5)-1)  (quarter_to_exhaustion_plus3:exp(_b[quarter_to_exhaustion_plus3])-1) (quarter_to_exhaustion_plus2:exp(_b[quarter_to_exhaustion_plus2])-1) (quarter_to_exhaustion_plus1:exp(_b[quarter_to_exhaustion_plus1])-1) (quarter_to_exhaustion_0:exp(_b[quarter_to_exhaustion_0])-1 )   (quarter_to_exhaustion_minus1:exp(_b[quarter_to_exhaustion_minus1])-1) (quarter_to_exhaustion_minus2:exp(_b[quarter_to_exhaustion_minus2])-1) (quarter_to_exhaustion_minus3:exp(_b[quarter_to_exhaustion_minus3])-1) (quarter_to_exhaustion_minus4:exp(_b[quarter_to_exhaustion_minus4])-1 ) , post
		estadd local SpellFE "Yes"
		estadd local SpellTimeFE "Yes"
		estadd local PBDFE "No"
est store m4

xi : xtpoisson ${var} ${MainQTE} ${OtherQTE}     										if balanced_sample==1 ,   fe vce(robust)
 nlcom     (Average: exp((_b[quarter_to_exhaustion_0]+_b[quarter_to_exhaustion_minus1]+_b[quarter_to_exhaustion_minus2]+_b[quarter_to_exhaustion_minus3]+_b[quarter_to_exhaustion_minus4])/5)-1)  (quarter_to_exhaustion_plus3:exp(_b[quarter_to_exhaustion_plus3])-1) (quarter_to_exhaustion_plus2:exp(_b[quarter_to_exhaustion_plus2])-1) (quarter_to_exhaustion_plus1:exp(_b[quarter_to_exhaustion_plus1])-1) (quarter_to_exhaustion_0:exp(_b[quarter_to_exhaustion_0])-1 )   (quarter_to_exhaustion_minus1:exp(_b[quarter_to_exhaustion_minus1])-1) (quarter_to_exhaustion_minus2:exp(_b[quarter_to_exhaustion_minus2])-1) (quarter_to_exhaustion_minus3:exp(_b[quarter_to_exhaustion_minus3])-1) (quarter_to_exhaustion_minus4:exp(_b[quarter_to_exhaustion_minus4])-1 ) , post
		estadd local SpellFE "Yes"
		estadd local SpellTimeFE "No"
		estadd local PBDFE "No"
est store m5

xi : xtpoisson ${var} ${MainQTE} ${OtherQTE} ${SpellTimeFE}    								if balanced_sample==1 ,   fe vce(robust)
 nlcom     (Average: exp((_b[quarter_to_exhaustion_0]+_b[quarter_to_exhaustion_minus1]+_b[quarter_to_exhaustion_minus2]+_b[quarter_to_exhaustion_minus3]+_b[quarter_to_exhaustion_minus4])/5)-1)  (quarter_to_exhaustion_plus3:exp(_b[quarter_to_exhaustion_plus3])-1) (quarter_to_exhaustion_plus2:exp(_b[quarter_to_exhaustion_plus2])-1) (quarter_to_exhaustion_plus1:exp(_b[quarter_to_exhaustion_plus1])-1) (quarter_to_exhaustion_0:exp(_b[quarter_to_exhaustion_0])-1 )   (quarter_to_exhaustion_minus1:exp(_b[quarter_to_exhaustion_minus1])-1) (quarter_to_exhaustion_minus2:exp(_b[quarter_to_exhaustion_minus2])-1) (quarter_to_exhaustion_minus3:exp(_b[quarter_to_exhaustion_minus3])-1) (quarter_to_exhaustion_minus4:exp(_b[quarter_to_exhaustion_minus4])-1 ) , post
		estadd local SpellFE "Yes"
		estadd local SpellTimeFE "Yes"
		estadd local PBDFE "No"
est store m6

******* Latex Table:

estout m1 m2 m3 m4 m5 m6  using "${path}Table3",  ///
keep (${MainQTE}    Average) order (${MainQTE}   Average ) ///
stats( PBDFE SpellTimeFE SpellFE N, labels(   "PBD-group FE" "Spell time FE" "Spell FE" "No. of Obs") fmt(%9.3f %9.3f %9.3f %9.0fc )) ///
style(tex) cells( b(star fmt(3)) se(par fmt(3)) )   starlevels( * 0.10 ** 0.05 *** 0.010) ///
mgroups("Full sample" "Balanced sample", pattern(1 0 0 0 1 0)  prefix(\multicolumn{@span}{c}{) suffix(})   span erepeat(\cmidrule(lr){@span})) ///
 title("The search effort of unemployed workers around benefits exhaustion") ///
  label legend  replace numbers mlabels(none)   collabels(none) 

******* Excel Table:
  
estout m1 m2 m3 m4 m5 m6  using "${path}Table3.xls",  ///
 keep (${MainQTE}  Average)  order (${MainQTE}  Average )  ///
 varlabel(quarter_to_exhaustion_plus3 "T-3" quarter_to_exhaustion_plus2 "T-2"  quarter_to_exhaustion_plus1 "T-1"  quarter_to_exhaustion_0 "T" quarter_to_exhaustion_minus1 "T+1" quarter_to_exhaustion_minus2 "T+2" quarter_to_exhaustion_minus3 "T+3" quarter_to_exhaustion_minus4 "T+4"  Average "T to T+4") ///
 cells( b(star fmt(3)) se(fmt(3)) )   starlevels( * 0.10 ** 0.05 *** 0.010)  ///
stats( PBDFE SpellTimeFE SpellFE N, labels(   "PBD-group FE" "Spell time FE" "Spell FE" "No. of Obs") fmt(%9.3f %9.3f %9.3f %9.0fc )) ///
 label legend  replace  title("The search effort of unemployed workers around benefits exhaustion") ///
 mlabels("1" "2" "3" "4" "5" "6")  mgroups("Full sample" "Balanced sample",  pattern(1 0 0 0 1 0))    collabels(none) 
 
 
 
 
***************************************************
******* TABLE 4 ***********************************
***************************************************



global var "ln_explained_monthly_w"

set  more off
estimates clear
xi : reghdfe ${var} ${MainQTE} ${OtherQTE}  	 						if no_missing_wage==1 ,   	absorb(PBD) cluster(spell_identifier)
nlcom    (quarter_to_exhaustion_plus3:_b[quarter_to_exhaustion_plus3] ) (quarter_to_exhaustion_plus2:_b[quarter_to_exhaustion_plus2] ) (quarter_to_exhaustion_plus1:_b[quarter_to_exhaustion_plus1] ) (quarter_to_exhaustion_0:_b[quarter_to_exhaustion_0] ) (quarter_to_exhaustion_minus1:_b[quarter_to_exhaustion_minus1]) (quarter_to_exhaustion_minus2:_b[quarter_to_exhaustion_minus2]) (quarter_to_exhaustion_minus3:_b[quarter_to_exhaustion_minus3]) (quarter_to_exhaustion_minus4:_b[quarter_to_exhaustion_minus4] )  (Average: (_b[quarter_to_exhaustion_0] + _b[quarter_to_exhaustion_minus1] + _b[quarter_to_exhaustion_minus2]+ _b[quarter_to_exhaustion_minus3] + _b[ quarter_to_exhaustion_minus4])/5)  , post
		estadd local SpellFE "No"
		estadd local SpellTimeFE "No"
		estadd local PBDFE "Yes"
est store m1

eststo: xi : reghdfe ${var} ${MainQTE} ${OtherQTE} ${SpellTimeFE}	 			if no_missing_wage==1 ,   	absorb(PBD) cluster(spell_identifier)
nlcom    (quarter_to_exhaustion_plus3:_b[quarter_to_exhaustion_plus3] ) (quarter_to_exhaustion_plus2:_b[quarter_to_exhaustion_plus2] ) (quarter_to_exhaustion_plus1:_b[quarter_to_exhaustion_plus1] ) (quarter_to_exhaustion_0:_b[quarter_to_exhaustion_0] ) (quarter_to_exhaustion_minus1:_b[quarter_to_exhaustion_minus1]) (quarter_to_exhaustion_minus2:_b[quarter_to_exhaustion_minus2]) (quarter_to_exhaustion_minus3:_b[quarter_to_exhaustion_minus3]) (quarter_to_exhaustion_minus4:_b[quarter_to_exhaustion_minus4] )  (Average: (_b[quarter_to_exhaustion_0] + _b[quarter_to_exhaustion_minus1] + _b[quarter_to_exhaustion_minus2]+ _b[quarter_to_exhaustion_minus3] + _b[ quarter_to_exhaustion_minus4])/5)  , post
		estadd local SpellFE "No"
		estadd local SpellTimeFE "Yes"
		estadd local PBDFE "Yes"
est store m2
		
eststo: xi : reghdfe ${var} ${MainQTE} ${OtherQTE}     							if no_missing_wage==1  ,   	absorb(spell_identifier) cluster(spell_identifier)
nlcom    (quarter_to_exhaustion_plus3:_b[quarter_to_exhaustion_plus3] ) (quarter_to_exhaustion_plus2:_b[quarter_to_exhaustion_plus2] ) (quarter_to_exhaustion_plus1:_b[quarter_to_exhaustion_plus1] ) (quarter_to_exhaustion_0:_b[quarter_to_exhaustion_0] ) (quarter_to_exhaustion_minus1:_b[quarter_to_exhaustion_minus1]) (quarter_to_exhaustion_minus2:_b[quarter_to_exhaustion_minus2]) (quarter_to_exhaustion_minus3:_b[quarter_to_exhaustion_minus3]) (quarter_to_exhaustion_minus4:_b[quarter_to_exhaustion_minus4] )  (Average: (_b[quarter_to_exhaustion_0] + _b[quarter_to_exhaustion_minus1] + _b[quarter_to_exhaustion_minus2]+ _b[quarter_to_exhaustion_minus3] + _b[ quarter_to_exhaustion_minus4])/5)  , post
		estadd local SpellFE "Yes"
		estadd local SpellTimeFE "No"
		estadd local PBDFE "No"
est store m3
	
eststo: xi : reghdfe ${var} ${MainQTE} ${OtherQTE}   ${SpellTimeFE} 			if no_missing_wage==1  ,   	absorb(spell_identifier) cluster(spell_identifier)
nlcom   (quarter_to_exhaustion_plus3:_b[quarter_to_exhaustion_plus3] ) (quarter_to_exhaustion_plus2:_b[quarter_to_exhaustion_plus2] ) (quarter_to_exhaustion_plus1:_b[quarter_to_exhaustion_plus1] ) (quarter_to_exhaustion_0:_b[quarter_to_exhaustion_0] ) (quarter_to_exhaustion_minus1:_b[quarter_to_exhaustion_minus1]) (quarter_to_exhaustion_minus2:_b[quarter_to_exhaustion_minus2]) (quarter_to_exhaustion_minus3:_b[quarter_to_exhaustion_minus3]) (quarter_to_exhaustion_minus4:_b[quarter_to_exhaustion_minus4] )  (Average: (_b[quarter_to_exhaustion_0] + _b[quarter_to_exhaustion_minus1] + _b[quarter_to_exhaustion_minus2]+ _b[quarter_to_exhaustion_minus3] + _b[ quarter_to_exhaustion_minus4])/5)  , post
		estadd local SpellFE "Yes"
		estadd local SpellTimeFE "Yes"
		estadd local PBDFE "No"
est store m4
		
eststo: xi : reghdfe ${var} ${MainQTE} ${OtherQTE}     							if no_missing_wage==1 & balanced_sample==1  ,   	absorb(spell_identifier) cluster(spell_identifier)
nlcom    (quarter_to_exhaustion_plus3:_b[quarter_to_exhaustion_plus3] ) (quarter_to_exhaustion_plus2:_b[quarter_to_exhaustion_plus2] ) (quarter_to_exhaustion_plus1:_b[quarter_to_exhaustion_plus1] ) (quarter_to_exhaustion_0:_b[quarter_to_exhaustion_0] ) (quarter_to_exhaustion_minus1:_b[quarter_to_exhaustion_minus1]) (quarter_to_exhaustion_minus2:_b[quarter_to_exhaustion_minus2]) (quarter_to_exhaustion_minus3:_b[quarter_to_exhaustion_minus3]) (quarter_to_exhaustion_minus4:_b[quarter_to_exhaustion_minus4] )  (Average: (_b[quarter_to_exhaustion_0] + _b[quarter_to_exhaustion_minus1] + _b[quarter_to_exhaustion_minus2]+ _b[quarter_to_exhaustion_minus3] + _b[ quarter_to_exhaustion_minus4])/5)  , post
		estadd local SpellFE "Yes"
		estadd local SpellTimeFE "No"
		estadd local PBDFE "No"
est store m5
		
eststo: xi : reghdfe ${var} ${MainQTE} ${OtherQTE} ${SpellTimeFE}   			if no_missing_wage==1 & balanced_sample==1   ,   	absorb(spell_identifier) cluster(spell_identifier)
nlcom   (quarter_to_exhaustion_plus3:_b[quarter_to_exhaustion_plus3] ) (quarter_to_exhaustion_plus2:_b[quarter_to_exhaustion_plus2] ) (quarter_to_exhaustion_plus1:_b[quarter_to_exhaustion_plus1] ) (quarter_to_exhaustion_0:_b[quarter_to_exhaustion_0] ) (quarter_to_exhaustion_minus1:_b[quarter_to_exhaustion_minus1]) (quarter_to_exhaustion_minus2:_b[quarter_to_exhaustion_minus2]) (quarter_to_exhaustion_minus3:_b[quarter_to_exhaustion_minus3]) (quarter_to_exhaustion_minus4:_b[quarter_to_exhaustion_minus4] )  (Average: (_b[quarter_to_exhaustion_0] + _b[quarter_to_exhaustion_minus1] + _b[quarter_to_exhaustion_minus2]+ _b[quarter_to_exhaustion_minus3] + _b[ quarter_to_exhaustion_minus4])/5)  , post
		estadd local SpellFE "Yes"
		estadd local SpellTimeFE "Yes"
		estadd local PBDFE "No"
est store m6

******* Latex Table:

estout  m1 m2 m3 m4 m5 m6 using "${path}Table4",  ///
keep (${MainQTE}    Average) order (${MainQTE}   Average ) ///
stats( PBDFE SpellTimeFE SpellFE N, labels(   "PBD-group FE" "Spell time FE" "Spell FE" "No. of Obs") fmt(%9.3f %9.3f %9.3f %9.0fc )) ///
style(tex) cells( b(star fmt(3)) se(par fmt(3)) )   starlevels( * 0.10 ** 0.05 *** 0.010) ///
mgroups("Full sample" "Balanced sample", pattern(1 0 0 0 1 0)  prefix(\multicolumn{@span}{c}{) suffix(})   span erepeat(\cmidrule(lr){@span})) ///
 title("The target wage of unemployed workers around benefits exhaustion") ///
  label legend  replace numbers mlabels(none)   collabels(none) 

******* Excel Table:
  
estout   m1 m2 m3 m4 m5 m6  using "${path}Table4.xls",  ///
 keep (${MainQTE}  Average)  order (${MainQTE}  Average )  ///
 varlabel(quarter_to_exhaustion_plus3 "T-3" quarter_to_exhaustion_plus2 "T-2"  quarter_to_exhaustion_plus1 "T-1"  quarter_to_exhaustion_0 "T" quarter_to_exhaustion_minus1 "T+1" quarter_to_exhaustion_minus2 "T+2" quarter_to_exhaustion_minus3 "T+3" quarter_to_exhaustion_minus4 "T+4"  Average "T to T+4") ///
 cells( b(star fmt(3)) se(fmt(3)) )   starlevels( * 0.10 ** 0.05 *** 0.010)  ///
stats( PBDFE SpellTimeFE SpellFE N, labels(   "PBD-group FE" "Spell time FE" "Spell FE" "No. of Obs") fmt(%9.3f %9.3f %9.3f %9.0fc )) ///
 label legend  replace  title("The target wage of unemployed workers around benefits exhaustion") ///
 mlabels("1" "2" "3" "4" "5" "6")  mgroups("Full sample" "Balanced sample",  pattern(1 0 0 0 1 0))    collabels(none) 
 
  
